﻿// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using Mono.Linker.Tests.TestCasesRunner;
using NUnit.Framework;

namespace Mono.Linker.Tests.TestCases
{
    [TestFixture]
    public class All
    {
        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.AdvancedTests))]
        public void AdvancedTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.AttributeDebuggerTests))]
        public void AttributesDebuggerTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.AttributesStructLayoutTests))]
        public void AttributesStructLayoutTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.AttributeTests))]
        public void AttributesTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.BCLFeaturesTests))]
        public void BCLFeaturesTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.BasicTests))]
        public void BasicTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.CodegenAnnotationTests))]
        public void CodegenAnnotationTests(TestCase testCase)
        {
            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
                Assert.Ignore("These tests are not valid when trimming .NET Framework");

#if NET
            Assert.Ignore("These tests are not valid when trimming .NET Core");
#endif
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.CommandLineTests))]
        public void CommandLineTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.ComponentModelTests))]
        public void ComponentModelTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.CoreLinkTests))]
        public void CoreLinkTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.CppCLITests))]
        public void CppCLITests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.DataFlowTests))]
        public void DataFlowTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.DynamicDependenciesTests))]
        public void DynamicDependenciesTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.ExtensibilityTests))]
        public void ExtensibilityTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.FeatureSettingsTests))]
        public void FeatureSettingsTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.FunctionPointersTests))]
        public void FunctionPointerTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.GenericsTests))]
        public void GenericsTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.InheritanceAbstractClassTests))]
        public void InheritanceAbstractClassTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.InheritanceComplexTests))]
        public void InheritanceComplexTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.InheritanceInterfaceTests))]
        public void InheritanceInterfaceTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.InheritanceVirtualMethodsTests))]
        public void InheritanceVirtualMethodsTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.InlineArrayTests))]
        public void InlineArrayTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.InteropTests))]
        public void InteropTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.LibrariesTests))]
        public void LibrariesTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.LinkAttributesTests))]
        public void LinkAttributesTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.LoggingTests))]
        public void LoggingTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.PreserveDependenciesTests))]
        public void PreserveDependenciesTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.ReferencesTests))]
        public void ReferencesTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.ReflectionTests))]
        public void ReflectionTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.RequiresCapabilityTests))]
        public void RequiresCapabilityTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.ResourcesTests))]
        public void ResourcesTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.SealerTests))]
        public void SealerTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.SerializationTests))]
        public void SerializationTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.SingleFileTests))]
        public void SingleFileTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.StaticsTests))]
        public void StaticsTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.SubstitutionsTests))]
        public void SubstitutionsTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.SymbolsTests))]
        public void SymbolsTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.TestFrameworkTests))]
        public void TestFrameworkTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.TopLevelStatementsTests))]
        public void TopLevelStatementsTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.TracingTests))]
        public void TracingTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.TypeForwardingTests))]
        public void TypeForwardingTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.UnreachableBlockTests))]
        public void UnreachableBlockTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.UnreachableBodyTests))]
        public void UnreachableBodyTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.WarningsTests))]
        public void WarningsTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.XmlTests))]
        public void XmlTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.LinqExpressionsTests))]
        public void LinqExpressionsTests(TestCase testCase)
        {
            Run(testCase);
        }

        [TestCaseSource(typeof(TestDatabase), nameof(TestDatabase.MetadataTests))]
        public void MetadataTests(TestCase testCase)
        {
            Run(testCase);
        }

        protected virtual void Run(TestCase testCase)
        {
            var runner = new TestRunner(new ObjectFactory());
            var linkedResult = runner.Run(testCase);
            new ResultChecker().Check(linkedResult);
        }
    }
}
